1 <?php
2 session_start();
// Use session variable on this page. This function must put on the top of page.
3 if
(!isset($_SESSION['username']) || $_SESSION['usertype'] !='admin'){ // if session variable "username" does not exist.
4 header(
"location:index.php?msg=Please%20login%20to%20access%20admin%20area%20!"); // Re-direct to index.php
5 }

6 else

7 {
8     include_once
"db.php";
9     error_reporting (E_ALL ^ E_NOTICE);
10
11
12 ?><!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
13 "http:
//www.w3.org/TR/html4/loose.dtd">
14 <html>
15 <head>
16 <title>Welcome to Stock Management System !</title>
17 <meta http-equiv=
"Content-Type" content="text/html; charset=iso-8859-1">
18 <link rel=
"stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
19         <link rel=
"stylesheet" href="css/template.css" type="text/css" media="screen" title="no title" charset="utf-8" />
20         <script src=
"js/jquery.min.js" type="text/javascript"></script>
21
22          <script src=
"js/jquery.hotkeys-0.7.9.js"></script>
23         <!-- AJAX SUCCESS TEST FONCTION
24             <script>function callSuccessFunction(){alert(
"success executed")}
25                     function callFailFunction(){alert(
"fail executed")}
26             </script>
27         -->
28         
29
30 <script LANGUAGE=
"JavaScript">
31 <!--

32 // Nannette Thacker http://www.shiningstar.net

33 function confirmSubmit()
34 {

35 var
agree=confirm("Are you sure you wish to Delete this Entry?");
36 if
(agree)
37     
return true ;
38 else

39     
return false ;
40 }
41
42 function confirmDeleteSubmit()
43 {

44 var
agree=confirm("Are you sure you wish to Delete Seletec Record?");
45 if
(agree)
46     
47 document.deletefiles.submit();

48 else

49     
return false ;
50 }
51
52
53 function checkAll()
54 {
55
56     
var field=document.forms.deletefiles;
57 for
(i = 0; i < field.length; i++)
58     field[i].
checked = true ;
59 }
60
61 function uncheckAll()
62 {
63     
var field=document.forms.deletefiles;
64 for
(i = 0; i < field.length; i++)
65     field[i].
checked = false ;
66 }

67 // -->

68 </script>
69         <script>
70         
71         
72         
73         
74         
75         $(document).ready(function() {
76             
// SUCCESS AJAX CALL, replace "success: false," by: success : function() { callSuccessFunction() },
77              $(
"#name").focus();
78             $(
"#form1").validationEngine(),
79             
80             jQuery(document).bind(
'keydown', 'Ctrl+s',function() {
81           $(
'#form1').submit();
82           
return false;
83             });
84             
85             jQuery(document).bind(
'keydown', 'Ctrl+r',function() {
86           $(
'#form1').reset();
87           
return false;
88             });
89             jQuery(document).bind(
'keydown', 'Ctrl+a',function() {
90             window.location =
"addstock.php";
91           
return false;
92             });
93             jQuery(document).bind(
'keydown', 'Ctrl+0',function() {
94             window.location =
"admin.php";
95           
return false;
96             });
97             jQuery(document).bind(
'keydown', 'Ctrl+1',function() {
98             window.location =
"add_purchase.php";
99               
return false;
100             });
101             jQuery(document).bind(
'keydown', 'Ctrl+2',function() {
102             window.location =
"add_stock_sales.php";
103               
return false;
104             });
105             jQuery(document).bind(
'keydown', 'Ctrl+3',function() {
106             window.location =
"add_stock_details.php";
107               
return false;
108             });
109             jQuery(document).bind(
'keydown', 'Ctrl+4',function() {
110             window.location =
"add_category.php";
111               
return false;
112             });
113             jQuery(document).bind(
'keydown', 'Ctrl+5',function() {
114             window.location =
"add_supplier_details.php";
115               
return false;
116             });
117             jQuery(document).bind(
'keydown', 'Ctrl+6',function() {
118             window.location =
"add_customer_details.php";
119               
return false;
120             });
121             jQuery(document).bind(
'keydown', 'Ctrl+7',function() {
122             window.location =
"view_stock_entries.php";
123               
return false;
124             });
125             jQuery(document).bind(
'keydown', 'Ctrl+8',function() {
126             window.location =
"view_stock_sales.php";
127               
return false;
128             });
129             jQuery(document).bind(
'keydown', 'Ctrl+9',function() {
130             window.location =
"view_stock_details.php";
131               
return false;
132             });
133             
//$.validationEngine.loadValidation("#date")
134             
//alert($("#formID").validationEngine({returnIsValid:true}))
135             
//$.validationEngine.buildPrompt("#date","This is an example","error") // Exterior prompt build example // input prompt close example
136             
//$.validationEngine.closePrompt(".formError",true) // CLOSE ALL OPEN PROMPTS
137         });
138     </script>
139 <style type=
"text/css">
140 <!--
141 body {
142     margin-left: 0px;
143     margin-top: 0px;
144     margin-right: 0px;
145     margin-bottom: 0px;
146     background-color: #FFFFFF;
147 }
148
149 *{
150 padding: 0px;
151 margin: 0px;
152 }
153 #vertmenu {
154 font-family: Verdana, Arial, Helvetica, sans-serif;
155 font-size:
100%;
156 width: 160px;
157 padding: 0px;
158 margin: 0px;
159 }
160
161 #vertmenu h1 {
162 display: block;
163 background-color:#FF9900;
164 font-size:
90%;
165 padding: 3px
0 5px 3px;
166 border: 1px solid #
000000;
167 color: #
333333;
168 margin: 0px;
169 width:159px;
170 }
171
172 #vertmenu ul {
173 list-style: none;
174 margin: 0px;
175 padding: 0px;
176 border: none;
177 }
178 #vertmenu ul li {
179 margin: 0px;
180 padding: 0px;
181 }
182 #vertmenu ul li a {
183 font-size:
80%;
184 display: block;
185 border-bottom: 1px dashed #C39C4E;
186 padding: 5px 0px 2px 4px;
187 text-decoration: none;
188 color: #
666666;
189 width:160px;
190 }
191
192 #vertmenu ul li a:hover, #vertmenu ul li a:focus {
193 color: #
000000;
194 background-color: #eeeeee;
195 }
196 .style1 {color: #
000000}
197 div.pagination {
198
199     padding: 3px;
200
201     margin: 3px;
202
203 }
204
205
206
207 div.pagination a {
208
209     padding: 2px 5px 2px 5px;
210
211     margin: 2px;
212
213     border: 1px solid #AAAADD;
214
215     
216
217     text-decoration: none;
/* no underline */
218
219     color: #
000099;
220
221 }
222
223 div.pagination a:hover, div.pagination a:active {
224
225     border: 1px solid #
000099;
226
227
228
229     color: #
000;
230
231 }
232
233 div.pagination span.current {
234
235     padding: 2px 5px 2px 5px;
236
237     margin: 2px;
238
239         border: 1px solid #
000099;
240
241         
242
243         font-weight: bold;
244
245         background-color: #
000099;
246
247         color: #FFF;
248
249     }
250
251     div.pagination span.disabled {
252
253         padding: 2px 5px 2px 5px;
254
255         margin: 2px;
256
257         border: 1px solid #EEE;
258
259     
260
261         color: #DDD;
262
263     }
264
265     
266 -->
267 </style>
268 </head>
269
270 <body>
271 <table width=
"100%" border="0" cellspacing="0" cellpadding="0">
272   <tr>
273     <td align=
"center" valign="top"><table width="960" border="0" cellspacing="0" cellpadding="0">
274       <tr>
275         <td><table width=
"960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
276           <tr>
277             <td height=
"90" align="left" valign="top"><img src="images/topbanner.jpg" width="960" height="82"></td>
278           </tr>
279           <tr>
280             <td height=
"800" align="left" valign="top"><table width="960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
281               <tr>
282                 <td width=
"130" align="left" valign="top">
283                 
284                 <br>
285
286                 <strong>Welcome <font color=
"#3399FF"><?php echo $_SESSION['username']; ?> !</font></strong><br> <br>
287 <table width=
"100%" border="0" cellspacing="0" cellpadding="0">
288   <tr>
289     <td align=
"center"><a href="admin.php"><img src="images/home.png" width="130" height="99" border="0"></a></td>
290     </tr>
291   <tr>
292     <td align=
"center">&nbsp;</td>
293     </tr>
294   <tr>
295     <td align=
"center"><a href="add_purchase.php"><img src="images/purchase.png" width="130" height="124" border="0"></a></td>
296     </tr>
297   <tr>
298     <td align=
"center">&nbsp;</td>
299     </tr>
300   <tr>
301     <td align=
"center"><a href="add_stock_sales.php"><img src="images/sales.png" width="146" height="111" border="0"></a></td>
302     </tr>
303   <tr>
304     <td align=
"center">&nbsp;</td>
305     </tr>
306   <tr>
307     <td align=
"center"><a href="report.php"><img src="images/reports.png" width="131" height="142" border="0"></a></td>
308     </tr>
309   <tr>
310     <td align=
"center">&nbsp;</td>
311     </tr>
312   <tr>
313     <td align=
"center">&nbsp;</td>
314     </tr>
315   <tr>
316     <td align=
"center">&nbsp;</td>
317     </tr>
318 </table>
319
320
321     
322                 
323                 
324                 </td> <td height=
"500" align="center" valign="top">
325 <table width=
"100%" border="0" cellspacing="0" cellpadding="0">
326   <tr>
327     <td><a href=
"add_stock_details.php"><img src="images/addstockdetails.png" width="67" height="62" border="0"></a></td>
328     <td><a href=
"add_supplier_details.php"><img src="images/supplier.png" width="67" height="54" border="0"></a></td>
329     <td><a href=
"add_customer_details.php"><img src="images/customer.png" width="67" height="54" border="0"></a></td>
330     <td><a href=
"add_category.php"><img src="images/categories.png" width="67" height="54" border="0"></a></td>
331     <td><a href=
"view_stock_sales.php"><img src="images/vsales.png" width="67" height="54" border="0"></a></td>
332     <td><a href=
"view_stock_entries.php"><img src="images/vpurchase.png" width="67" height="54" border="0"></a></td>
333     <td><a href=
"view_stock_details.php"><img src="images/stockdetails.png" width="67" height="54" border="0"></a></td>
334     <td><a href=
"view_stock_availability.php"><img src="images/savail.png" width="67" height="54" border="0"></a></td>
335      <td align=
"left" valign="top"><a href="view_customer_details.php"><img src="images/customers.png" width="94" height="22" border="0"></a><br> <a href="view_supplier_details.php"><img src="images/suppliers.png" width="94" height="22" border="0"></a><br>
336       <a href=
"view_payments.php"><img src="images/payments.png" width="94" height="22" border="0"></a></td>
337     <td align=
"left" valign="top"><a href="view_stock_sales_payments.php"><img src="images/outstanding.png" width="94" height="22" border="0"></a><br> <a href="view_stock_entries_payments.php"><img src="images/pendings.png" width="94" height="22" border="0"></a><br>
338       <a href=
"logout.php"><img src="images/logout.png" width="94" height="22" border="0"></a></td>
339   </tr>
340 </table>
341 <table width=
"700" border="0" cellspacing="0" cellpadding="0">
342   <tr>
343     <td><form action=
"" method="post" name="search" >
344 <input name=
"searchtxt" type="text">
345 &nbsp;&nbsp;<input name=
"Search" type="submit" value="Search">
346 </form></td>
347     <td><form action=
"" method="get" name="page">
348 Page per Record<input name=
"limit" type="text" style="margin-left:5px;" value="<?php if(isset($_GET['limit'])) echo $_GET['limit']; else echo "10"; ?>" size="3" maxlength="3">
349 <input name=
"go" type="submit" value="Go">
350 <input type=
"button" name="selectall" value="SelectAll" onClick="checkAll()" style="margin-left:5px;"/>
351 <input type=
"button" name="unselectall" value="DeSelectAll" onClick="uncheckAll()" style="margin-left:5px;" />
352 <input name=
"dsubmit" type="button" value="Delete Selected" style="margin-left:5px;" onclick="return confirmDeleteSubmit()"/></form></td>
353   </tr>
354 </table>
355
356                 <?php
357
358
359
360 $SQL =
"SELECT * FROM customer_details";
361 if
(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
362 {
363
364 $SQL =
"SELECT * FROM customer_details WHERE customer_name LIKE '%".$_POST['searchtxt']."%' OR customer_address LIKE '%".$_POST['searchtxt']."%' OR customer_contact1 LIKE '%".$_POST['searchtxt']."%' OR customer_contact2 LIKE '%".$_POST['searchtxt']."%'";
365
366
367 }
368
369     $tbl_name=
"customer_details"; //your table name
370
371     
// How many adjacent pages should be shown on each side?
372
373     $adjacents =
3;
374
375     
376
377     
/*
378
379        First
get total number of rows in data table.
380
381        If you have a WHERE clause
in your query, make sure you mirror it here.
382
383     */

384
385     $query =
"SELECT COUNT(*) as num FROM $tbl_name";
386     
if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
387 {
388
389 $query =
"SELECT COUNT(*) as num FROM customer_details WHERE customer_name LIKE '%".$_POST['searchtxt']."%' OR customer_address LIKE '%".$_POST['searchtxt']."%' OR customer_contact1 LIKE '%".$_POST['searchtxt']."%' OR customer_contact2 LIKE '%".$_POST['searchtxt']."%'";
390
391
392 }
393
394
395     $total_pages = mysql_fetch_array(mysql_query($query));
396
397     $total_pages = $total_pages[num];
398
399     
400
401     
/* Setup vars for query. */
402
403     $targetpage =
"view_customer_details.php"; //your file name (the name of this file)
404
405     $limit =
10; //how many items to show per page
406 if
(isset($_GET['limit']))
407     $limit=$_GET[
'limit'];
408     
409
410     $page = $_GET[
'page'];
411
412     
if($page)
413
414         $start = ($page -
1) * $limit; //first item to display on this page
415
416     
else
417
418         $start =
0; //if no page var is given, set start to 0
419
420     
421
422     
/* Get data. */
423
424     $sql =
"SELECT * FROM customer_details LIMIT $start, $limit ";
425     
if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
426 {
427
428     $sql=
"SELECT * FROM customer_details WHERE customer_name LIKE '%".$_POST['searchtxt']."%' OR customer_address LIKE '%".$_POST['searchtxt']."%' OR customer_contact1 LIKE '%".$_POST['searchtxt']."%' OR customer_contact2 LIKE '%".$_POST['searchtxt']."%' LIMIT $start, $limit";
429
430
431 }
432
433
434     $result = mysql_query($sql);
435
436     
437
438     
/* Setup page vars for display. */
439
440     
if ($page == 0) $page = 1; //if no page var is given, default to 1.
441
442     $prev = $page -
1; //previous page is page - 1
443
444     $next = $page +
1; //next page is page + 1
445
446     $lastpage = ceil($total_pages/$limit);
//lastpage is = total pages / items per page, rounded up.
447
448     $lpm1 = $lastpage -
1; //last page minus 1
449
450     
451
452     
/*
453
454         Now we apply our rules and draw the pagination
object.
455
456         We
're actually saving the code to a variable in case we want to draw it more than once.
457
458     */

459
460     $pagination =
"";
461
462     
if($lastpage > 1)
463
464     {
465
466         $pagination .=
"<div class=\"pagination\">";
467
468         
//previous button
469
470         
if ($page > 1)
471
472             $pagination.=
"<a href=\"$targetpage?page=$prev&limit=$limit\">« previous</a>";
473
474         
else
475
476             $pagination.=
"<span class=\"disabled\">« previous</span>";
477
478         
479
480         
//pages
481
482         
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
483
484         {
485
486             
for ($counter = 1; $counter <= $lastpage; $counter++)
487
488             {
489
490                 
if ($counter == $page)
491
492                     $pagination.=
"<span class=\"current\">$counter</span>";
493
494                 
else
495
496                     $pagination.=
"<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
497
498             }
499
500         }
501
502         elseif($lastpage >
5 + ($adjacents * 2)) //enough pages to hide some
503
504         {
505
506             
//close to beginning; only hide later pages
507
508             
if($page < 1 + ($adjacents * 2))
509
510             {
511
512                 
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
513
514                 {
515
516                     
if ($counter == $page)
517
518                         $pagination.=
"<span class=\"current\">$counter</span>";
519
520                     
else
521
522                         $pagination.=
"<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
523
524                 }
525
526                 $pagination.=
"...";
527
528                 $pagination.=
"<a href=\"$targetpage?page=$lpm1&limit=$limit\">$lpm1</a>";
529
530                 $pagination.=
"<a href=\"$targetpage?page=$lastpage&limit=$limit\">$lastpage</a>";
531
532             }
533
534             
//in middle; hide some front and some back
535
536             elseif($lastpage - ($adjacents *
2) > $page && $page > ($adjacents * 2))
537
538             {
539
540                 $pagination.=
"<a href=\"$targetpage?page=1&limit=$limit\">1</a>";
541
542                 $pagination.=
"<a href=\"$targetpage?page=2&limit=$limit\">2</a>";
543
544                 $pagination.=
"...";
545
546                 
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
547
548                 {
549
550                     
if ($counter == $page)
551
552                         $pagination.=
"<span class=\"current\">$counter</span>";
553
554                     
else
555
556                         $pagination.=
"<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
557
558                 }
559
560                 $pagination.=
"...";
561
562                 $pagination.=
"<a href=\"$targetpage?page=$lpm1&limit=$limit\">$lpm1</a>";
563
564                 $pagination.=
"<a href=\"$targetpage?page=$lastpage&limit=$limit\">$lastpage</a>";
565
566             }
567
568             
//close to end; only hide early pages
569
570             
else
571
572             {
573
574                 $pagination.=
"<a href=\"$targetpage?page=1&limit=$limit\">1</a>";
575
576                 $pagination.=
"<a href=\"$targetpage?page=2&limit=$limit\">2</a>";
577
578                 $pagination.=
"...";
579
580                 
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
581
582                 {
583
584                     
if ($counter == $page)
585
586                         $pagination.=
"<span class=\"current\">$counter</span>";
587
588                     
else
589
590                         $pagination.=
"<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
591
592                 }
593
594             }
595
596         }
597
598         
599
600         
//next button
601
602         
if ($page < $counter - 1)
603
604             $pagination.=
"<a href=\"$targetpage?page=$next&limit=$limit\">next »</a>";
605
606         
else
607
608             $pagination.=
"<span class=\"disabled\">next »</span>";
609
610         $pagination.=
"</div>\n";
611
612     }
613
614 ?>
615
616     <form name=
"deletefiles" action="deleteselected.php" method="post">
617      <input name=
"table" type="hidden" value="customer_details">
618      <input name=
"return" type="hidden" value="view_customer_details.php">
619
620       <table width=
"700" border="0" cellspacing="0" cellpadding="0">
621
622       <tr>
623
624         <td bgcolor=
"#0099FF"><div align="center"><strong><span class="style1">View Supplier Details </span></strong></div></td>
625
626       </tr>
627
628       <tr>
629
630         <td>&nbsp;</td>
631
632       </tr>
633
634       <tr>
635
636         <td align=
"center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
637
638           <tr>
639
640             <td width=
"100"><strong>Supplier Name </strong></td>
641
642             <td width=
"100"><strong>Supplier Address</strong></td>
643
644             <td width=
"100"><strong>Supplier Contact1 </strong></td>
645
646             <td width=
"100"><strong>Supplier Cotact 2 </strong></td>
647             <td width=
"100"><strong>View/Edit</strong></td>
648             <td width=
"100"><strong>Delete</strong></td>
649             <td width=
"100"><strong>Select</strong></td>
650           
651           </tr>
652
653           
654
655           
656
657           <?php
658
659      
660
661                                 
while($row = mysql_fetch_array($result))
662
663         {
664
665         
666
667          $mysqldate=$row[
'date'];
668
669         $phpdate = strtotime( $mysqldate );
670
671         $phpdate = date(
"d/m/Y",$phpdate);
672
673
674
675                                          ?>
676
677                                             <tr>
678
679
680
681         <td width=
"100"><?php echo $row['customer_name']; ?></td>
682
683         <td width=
"100"><?php echo $row['customer_address']; ?></td>
684
685         <td width=
"100"><?php echo $row['customer_contact1']; ?></td>
686
687         
688
689         <td width=
"100"><?php echo $row['customer_contact2']; ?></td>
690         <td width=
"100"> <a href="update_customer_details.php?sid=<?php echo $row['id'];?>"><img src="images/edit-icon.png" border="0" alt="delete"></a></td>
691         <td width=
"100"><a onclick="return confirmSubmit()" href="delete.php?id=<?php echo $row['id']; ?>&table=customer_details&return=view_customer_details.php"><img src="images/delete.png" border="0" alt="delete"></a></td>
692         <td width=
"100">&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" value="<?php echo $row['id']; ?>" name="checklist[]" /></td>
693
694                             </tr>
695
696                                              
697
698                                              
699
700                                         
701
702                                              
703
704                                              <?php
705
706                                                 
707
708                                              
709
710                                       }
711
712                                         
713
714                       
715
716                           
717
718     
719
720  
721
722
723
724 ?>
725
726           
727
728           
729
730           
731
732           
733
734           
735
736         </table></td>
737
738       </tr>
739
740       <tr>
741
742         <td>&nbsp;</td>
743
744       </tr>
745
746       <tr>
747
748         <td align=
"center">&nbsp;</td>
749
750       </tr>
751
752       <tr>
753
754         <td align=
"center"><div style="margin-left:20px;"><?php echo $pagination; ?></div></td>
755
756       </tr>
757
758       <tr>
759
760         <td align=
"center">&nbsp;</td>
761
762       </tr>
763
764       <tr>
765
766         <td>&nbsp;</td>
767
768       </tr>
769
770       <tr>
771
772         <td align=
"center">&nbsp; </td>
773
774       </tr>
775
776       <tr>
777
778         <td>&nbsp;</td>
779
780       </tr>
781
782     </table>
783
784     
785
786     </form>
787
788     
789
790     </td>
791
792   </tr>
793
794 </table>
795
796 </td>
797               </tr>
798             </table>
799             
800         </td>
801           </tr>
802           <tr>
803             <td height=
"30" align="center" bgcolor="#72C9F4"><span class="style1"><a href="http://www.pluskb.com">Developed by PlusKB Innovations</a></span></td>
804           </tr>
805         </table></td>
806       </tr>
807     </table></td>
808   </tr>
809 </table>
810
811 </body>
812 </html>
813 <?php
814 }
815 ?>


Gõ tìm kiếm nhanh...